home *** CD-ROM | disk | FTP | other *** search
-
- // Takes care of the maze; it knows all the maze templates, parses the "mazes"
- // file in the .app wrapper, and knows which dots have been eaten.
-
- #import <appkit/appkit.h>
-
- // how many mazes are available
- #define MAZES 6
-
- // image size in pixels; they are square
- #define GHOST_SIZE 16
- #define PER_ROW 6 // number of maze blocks per row in Maze.tiff
-
- // size of maze in # of images (blocks)
- #define BLOCK_WIDTH 21
- #define BLOCK_HEIGHT 16
-
- // the view _must_ have these dimensions:
- #define WIN_WIDTH GHOST_SIZE * BLOCK_WIDTH
- #define WIN_HEIGHT GHOST_SIZE * BLOCK_HEIGHT
-
- // max # of these things:
- #define MAX_GHOSTS 4
- #define MAX_POWER_DOTS 4
-
- // useful macros:
- #define sgn(x) ((x) ? (((x) > 0) ? 1 : -1) : 0)
- #define abs(x) (((x) < 0) ? -(x) : (x))
-
- // point values
- #define DOTPOINTS 10
- #define POWERDOTPOINTS 50
-
- // maze parts (indices)
- #define GHDOOR 5
- #define PLAYER 7
- #define GHOST 10
- #define EMPTY 8
- #define DOT 28
- #define POWER 29
-
- @interface Maze:Object
- {
- id mazeParts[3]; // NXImage with Maze.tiff in it.
- int mazeNum; // which maze is currently displayed; between 0 and MAZES-1
- char mazes[MAZES][BLOCK_WIDTH][BLOCK_HEIGHT]; // holds base maze data
- char maze[BLOCK_WIDTH][BLOCK_HEIGHT]; // holds working copy of maze data
- int power[MAX_POWER_DOTS * 2]; // locations of power dots
- int ghosts[MAX_GHOSTS * 2]; // starting ghost locations
- int player[2]; // starting player/fruit position
- int door[2]; // ghost chamber door position
- int dots; // number of dots left in current maze
- int dotx, doty; // (x, y) of last dot eaten
- BOOL powerDotShown; // whether or not to draw a power dot
- BOOL visibleMaze; // whether or not to draw the maze
- int scale;
- }
-
- - init;
- - render:(NXRect *)rect at:(NXPoint *)pos; // used to render
- // lockfocus in the view where it's drawn first.
- - makeMaze:(int)num; // loads maze into working array and sets
- // up ghost/power dot/player locations
- - playerPosition:(int *)x :(int *)y; // return x, y of player/fruit
- - doorPosition:(int *)x :(int *)y; // return x, y of door to ghost chamber
- - (const int *)powerDot; // return pointer to power array
- - (const int *)ghosts; // return pointer to ghosts array
- - (BOOL)powerDotAt:(int)x :(int)y; // return YES if power dot in block
- - (BOOL)eatDotAt:(int)x :(int)y; // return YES if OK, NO if no dot was there
- - (int)dots; // return the number of dots left in maze
- - (BOOL)playerWall:(float)x :(float)y; // YES if player can't be in block
- - (BOOL)monsterWall:(float)x :(float)y; // YES if ghost can't be in block
- - blinkPowerDot; // toggle ON/OFF state of power dots
- - lastDot:(int *)xx :(int *)yy; // returns (x,y) of last dot eaten
- - visible:(BOOL)flag; // used to tell us if the maze is visible
- - (BOOL)isVisible; // used to tell others if maze is visible
- - (int)scale;
- - setScale:(int)newScale;
-
-
- @end
-